<template>
	<view>
		<view class="grid text-center padding-sm" :class="['col-' + cols, gridBorder ? '' : 'no-border']">
			<view v-for="(item,index) in datas" :key="index" @click="onClick" :data-index="index">
				<view>{{item.value}}</view>
				<view>{{item.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {};
	},
	name: 'cu-custom',
	computed: {
		style() {
			var style = '';
			return style;
		}
	},
	props: {
		datas: Array,
		cols:  {
			type: [Number,String],
			default: 3
		},
		gridBorder: {
			type: [Boolean, String],
			default: false
		}
	},
	methods: {
		onClick(e) {
			var index = e.currentTarget.dataset.index;
			if(this.datas.length<=index){
				this.$util.showAlert("缺少跳转路径");
				return;
			}
			let item=this.datas[index];
			//console.log(good)
			if(!item.path){
				//this.$util.showAlert("缺少跳转路径");
				 this.$emit('onchange', index);
				return;
			}
			this.$util.redirectTo(item.path,item);
		}
	}
};
</script>

<style scoped></style>
